package com.wn.servlet.demo03;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yellow Docter
 * @date 2022 -06-29
 * @desc
 */
@WebServlet("/path")
public class PathServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //重定向  客户端路径
//        response.sendRedirect("/day03/success.html");

        System.out.println("PathServlet.getRequestDispatcher");
        // 转发是服务器 内部操作
        //  / 当前服务器下面的项目:   http://localhost:8080/项目名/
//        request.getRequestDispatcher("/success.html").forward(request,response);

//        request.getRequestDispatcher("/page/page.html").forward(request,response);

        request.getRequestDispatcher("/code").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("PathServlet.doGet");
        this.doPost(request, response);
    }

}
